<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Offerwalls extends CI_Controller {

	public function __construct(){
		parent::__construct();

		// load helper
		$this->load->helper('url');
		$this->load->library('session');

		/* load model */
		$this->load->model("State", '', TRUE);
		$this->load->model("Country", '', TRUE);
		$this->load->model("Authentication", '', TRUE);
		$this->load->model("Member", '', TRUE);
		$this->load->model("Fraud", '', TRUE);
		$this->load->model("Network", '', TRUE);
	}	

	public function index(){
		
		if (!$this->Authentication->IsAuthenticated_Session()){
			redirect('/members/login');
		}
		
		$data['walls'] = $this->Network->getNetworksByType(WALL);

		$data['mainView'] = 'index';
        $data['controllerName'] = 'offerwalls';
        $this->load->view('layouts/layout', $data);
	}


	public function wall($networkId){
		
		if (!$this->Authentication->IsAuthenticated_Session()){
			redirect('/members/login');
		}
		
		$wall = $this->Network->getWall($networkId);	
		$data['iframe_src'] = str_replace('(PUB_ID)', $wall->pubIdOrAppId, $wall->href).$this->session->userdata('username');


		$data['mainView'] = 'wall';
        $data['controllerName'] = 'offerwalls';
        $this->load->view('layouts/layout', $data);
	}
}// end class